export class ArrayHelp<T> {

    constructor(private arr:T[]){}

    // 取数组中是前 n 项
    take( n: number): T[] {
        if (n >= this.arr.length) return this.arr
        const newArr: T[] = []
        for (let i = 0; i < n; i++) {
            newArr.push(this.arr[i])
        }
        return newArr
    }

    // 数组打乱顺序
    shuffle(): T[] {
        return this.arr.sort(() => Math.random() - 0.5)
    }

}

